<template>
    <div>使用IndexDB</div>
    <el-button type="primary" @click="add">添加数据</el-button>
    <el-button type="primary" @click="get">获取数据</el-button>
    <el-button type="primary" @click="remove">删除数据</el-button>
    <el-button type="primary" @click="update">更新数据</el-button>
</template>

<script setup lang="ts">
import IndexDB from "@/utils/storage";
//添加数据
const add = async () => {
    await IndexDB.add('data13', '213');
    console.log(IndexDB.get('data13'));
};
//获取数据
const get = async () => {
    // await IndexDB.add('data', '2');
    const data = (await IndexDB.get('data1')).content;
    console.log(data);
};
//删除数据
const remove = async () => {
    await IndexDB.remove('data');
    console.log(IndexDB.get('data'));
};
//更新数据
const update = async () => {
    await IndexDB.update('data1', '2555');
    console.log(IndexDB.get('data'));
};
// update();

</script>
